import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:new_yuqib_app/yqbConfig/tencent_im_utils.dart';
import 'package:new_yuqib_app/yqbConfig/yqb_app.dart';
import 'package:new_yuqib_app/yqbNetwork/api_metholds.dart';
import 'package:new_yuqib_app/yqbView/loginView/view.dart';

class SetController extends GetxController{
  @override
  void onInit() {
    super.onInit();
  }

  ///注销
  logOut(){
    EasyLoading.show(status: "注销中...");
    ApiMethods.logOut().then((value){
      EasyLoading.dismiss();
      signOut();
    }).catchError((err){
      EasyLoading.dismiss();
    });
  }

  ///退出app的操作
  quiltApp()async{
    if(YqbApp.getServiceData() !=null){
      await TencentImUtils.deleteConversion(YqbApp.getServiceData()!.serviceTencentId);
    }
  }

  ///退出登录
  signOut(){
    quiltApp();
    YqbApp.logOut();
    Get.offAll(const LoginView());
  }

  ///清楚缓存
  cleanPreference(){
    EasyLoading.show(status: "清除缓存中...");
    Future.delayed(const Duration(seconds: 1),(){
      EasyLoading.dismiss();
    });
  }
}